#include "stdafx.h"
#include "sound_manager.hpp"

namespace FndGame2D {
    bool sound_manager::add_sound(const sound_manager::key_type& k,
                                  sound_manager::value_type* sound) {
        return m_sound_mgr.insert(k,std::auto_ptr<value_type>(sound)).second ;
    }
    bool sound_manager::add_sound(const sound_manager::key_type& k,
                                  sf::SoundBuffer* buffer,
                                  bool loop,
                                  float pitch,
                                  float valume,
                                  const sf::Vector3f& position) {

        std::auto_ptr<sf::Sound> p(new sf::Sound(*buffer,
                                                 loop,
                                                 pitch,
                                                 valume,
                                                 position)) ;
        return m_sound_mgr.insert(k,p).second ;
    }

    bool sound_manager::add_music(const sound_manager::key_type& k,
                                  sf::Music* music) {
        return m_music_mgr.insert(k, std::auto_ptr<sf::Music>(music)).second ;
    }
    bool sound_manager::add_music(const sound_manager::key_type& k,
                                  size_t buffer_size) {
        std::auto_ptr<sf::Music> music(new sf::Music(buffer_size)) ;
        return m_music_mgr.insert(k, music).second ;
    }
    bool sound_manager::add_music(const sound_manager::key_type& k,
                                  const char* file_name,
                                  size_t buffer_size) {
        std::auto_ptr<sf::Music> music(new sf::Music(buffer_size)) ;
        if(!music->OpenFromFile(file_name)) 
            return false ;
        else 
            return m_music_mgr.insert(k, music).second ;
    }
} 
